/*
 * MovementHandler.h
 *
 *  Created on: 28/10/2013
 *      Author: fernando
 */

#ifndef MOVEMENTHANDLER_H_
#define MOVEMENTHANDLER_H_

#include "TableroSDL.h"
#include "../logica/Partida.h"

const unsigned int MAXPIXELMOV = 64;

class MovementHandler {
public:
	MovementHandler(TableroSDL*);
	virtual ~MovementHandler();
	void pulsaGolosina();
	void ubicarMouse(unsigned int, unsigned int);
	void moverGolosina();
	int soltarGolosina();
	void destruirGolosina(CeldaSDL*);
	void destruirGolosinas(std::vector<int>);
	void bajarGolosina(unsigned int);
	void reponerGolosina(Golosina*, unsigned int columna);
	void reponerGolosinas(std::vector<Golosina*>, unsigned int columna);
	static Golosina* getGolosinaRandom(unsigned int x, unsigned int y);
	static Golosina* getGolosinaRandom();
	void intercambiar(unsigned int nCelda1, unsigned int nCelda2);
	void setPartida(Partida*);
	void eliminarYRellenarPosiciones();
    unsigned int getCeldaFromPos(unsigned int nCol, unsigned int nFil);


private:
	bool limiteAlcanzado;
	bool mouseApretado;
	Golosina* golosinaOrigen;
	Golosina* golosinaDestino;
	unsigned int xOrigen;
	unsigned int yOrigen;
	unsigned int xActual;
	unsigned int yActual;
	int direccion;//puede ser horizontal o vertical
	TableroSDL* tablero;
	Partida* partida;
};

#endif /* MOVEMENTHANDLER_H_ */
